package czk.concrent.threadstatus;

/**
 * @Author:ChenZhangKun
 * @Date: 2020/5/2 21:14
 */
public class InteruptTest {
    public static void main(String[] args) throws InterruptedException {
        Thread thread=new Thread(()->{
           while (true){
               //System.out.println(1);
               // 判断
               boolean interrupted = Thread.currentThread().isInterrupted();
          //     System.out.println(interrupted);
               if (interrupted){
                   System.out.println("线程被打断了");
                   break;
               }
           }
        });
        thread.start();
        Thread.sleep(1*1000);
        System.out.println("打断线程");
        thread.interrupt();

    }
}
